<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/woniu/Public/X-admin/css/x-admin.css" media="all">
</head>
<body>
        <div class="x-body">
            <form class="layui-form layui-form-pane" action="" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发送人
                    </label>
                    <div class="layui-input-block">
                       <input type="text" name="addresser" id="addresser" required  lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <br>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">
                      标题
                    </label>
                    <div class="layui-input-block">
                       <input type="text" name="title" id="title" required  lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <br>

                <div class="layui-form-item layui-form-text">
                    <div class="layui-input-block">
                        <textarea name="contents" id="contents" style="display: none;">请输入详细信息</textarea>
                    </div>
                      <label for="L_content" class="layui-form-label" style="top: -2px;">
                          描述
                      </label>
                </div>

                <div class="layui-form-item">
                    <!-- <label class="layui-form-label" style="background-color: white;border:0px;">
                        是否匿名：
                    </label>
                    <div class="layui-input-block">
                       <input type="checkbox" name="anonymity" lay-skin="switch" lay-text="ON|OFF" lay-filter="anonymity">
                        <span class="x-red">&nbsp;&nbsp;&nbsp;&nbsp;*</span><span style="color:#696969;">如果开启,则匿名发送</span> -->
                        <button class="layui-btn" lay-submit lay-filter="add" style="float: right; margin-right:50px">存为草稿</button>
                    </div>
                       
                </div>
            </form>
        </div>
  </body>
</html>
  
   <script src="/woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8"></script>
   <script src="/woniu/Public/X-admin/js/x-layui.js" charset="utf-8"></script>
   <script>
    layui.use(['form','layer'], function(){
          $ = layui.jquery;
          var form = layui.form();
          layer = layui.layer;

          //建立编辑器
          layui.use('layedit', function(){
               layedit = layui.layedit;
               indexedit = layedit.build('contents',{
                hideTool: ['image']
              }); 
              layedit.sync(indexedit);
            });


          //监听提交
          form.on('submit(add)', function(data){

            //获取数据的value值
            title=$("#title").val();               
            addresser=$("#addresser").val();
            contents = document.getElementById('contents').value=layedit.getContent(indexedit);

            //$.post传值
            $.post('/woniu/index.php/Home/Notice/inserts',{title:title,addresser:addresser,contents:contents},function(data){
                if(data==1){
                  layer.alert("添加成功", {icon:6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.reload();
                  });
               }else{
                 layer.msg('添加失败',{icon:2});
               }
            });
           return false;
         });
      }); 
 </script>